package com.mp.approvalreq.dao;

import com.mp.approvalreq.entity.Leave;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public interface LeaveDao {

    /**
     * 插入请假套件信息
     *
     * @param leave
     * @throws SQLException
     */
    void insertLeave(Leave leave) throws SQLException;

    /**
     * 批量插入请假信息
     *
     * @param leaves
     * @throws SQLException
     */
    void insertBatchLeave(List<Leave> leaves) throws SQLException;

    /**
     * 保存销假信息
     *
     * @param leave
     * @throws SQLException
     */
    void insertPauseLeaveInfo(Leave leave) throws SQLException;

    /**
     * 根据审批id获取最后一条请假套件详情记录
     *
     * @param requestId
     * @return
     * @throws SQLException
     */
    Leave selectLastLeaveByRequestId(Integer requestId) throws SQLException;

    /**
     * 根据审批id获取第一条请假套件详情记录
     *
     * @param requestId
     * @return
     * @throws SQLException
     */
    Leave selectFirstLeaveByRequestId(Integer requestId) throws SQLException;

    /**
     * 作废请假
     *
     * @param leave
     * @throws SQLException
     */
    void deleteLeave(Leave leave) throws SQLException;

    /**
     * 批量作废请假
     *
     * @param leaves
     * @throws SQLException
     */
    void deleteBatchLeave(List<Leave> leaves) throws SQLException;

    /**
     * 作废请假
     *
     * @param requestId
     * @param companyId
     * @throws SQLException
     */
    void deleteLeaveByRequestId(Integer requestId, Integer companyId) throws SQLException;

    /**
     * 查询用户请假次数,按祖先模板分组
     *
     * @param companyId
     * @param companyInfoId
     * @param month
     * @return
     * @throws SQLException
     */
    Map<Integer, Integer> selectUserLeaveTimesMapByMonth(Integer companyId, Integer companyInfoId, String month) throws SQLException;

    /**
     * 根据类型查询用户请假集合
     *
     * @param companyId
     * @param companyInfoId
     * @param leaveType
     * @return
     * @throws SQLException
     */
    List<Leave> selectUserLeavesByLeaveType(Integer companyId, Integer companyInfoId, String leaveType) throws SQLException;

    /**
     * 查询全公司指定时间范围的请假集合(简化版)
     *
     * @param companyId
     * @param startTime
     * @param endTime
     * @return
     * @throws SQLException
     */
    List<Leave> selectCompanyLeavesByDateScope(Integer companyId, String startTime, String endTime) throws SQLException;

    /**
     * 查询全公司所有请假详情
     * @param companyId
     * @param startTime
     * @param endTime
     * @return
     * @throws SQLException
     */
    List<Leave> selectCompanyLeaveDetailsByDateScope(Integer companyId, String startTime, String endTime) throws SQLException;
    /**
     * 批量查询用户指定时间范围的请假集合
     *
     * @param companyId
     * @param companyInfoIds
     * @param startTime
     * @param endTime
     * @return
     * @throws SQLException
     */
    List<Leave> selectBatchUserLeavesByDateScope(Integer companyId, String companyInfoIds, String startTime, String endTime) throws SQLException;

    /**
     * 根据id批量查询请假集合
     *
     * @param requestIds
     * @return
     * @throws SQLException
     */
    Map<Integer, Leave> selectLeavesByRequestIds(String requestIds) throws SQLException;


}
